package com.orange.cetback.controller.user;

import com.orange.cetback.common.vo.Result;
import com.orange.cetback.pojo.dto.ExamPapersDTO;
import com.orange.cetback.pojo.entity.ExamPapers;
import com.orange.cetback.service.ExamPapersService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenenjun
 * @since 2025-02-16
 */
@Slf4j
@Tag(name = "试卷接口")
@RestController
@RequestMapping("/userApi/examPapers")
public class ExamPapersController {
    @Autowired
    private ExamPapersService examPapersService;

    @Operation(summary = "获取试卷列表")
    @PostMapping("/list")
    public Result<List<ExamPapers>> list(@RequestBody ExamPapersDTO examPapersDTO) {
        log.info("获取试卷列表:{}",examPapersDTO);
        List<ExamPapers> list = examPapersService.list(examPapersDTO);
        return Result.success(list);
    }

    @Operation(summary = "保存试卷")
    @PostMapping("/save")
    public Result<String> save(@RequestBody ExamPapers examPapers){
        examPapersService.save(examPapers);
        return Result.success("保存成功");
    }
}
